#include<bits/stdc++.h>
using namespace std;
const int N=100005;

int T,n,m,L,V,d[N],v[N],a[N],p[N],cs[N],ans2,ans1,csp[N];

int judge(int d,int v,int a,int V){
    if(sqrt(v*v+2*a*d)>V)return true;
    return false;
}

int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    for(int t=1;t<=T;t++){
        ans1=0,ans2=0;
        for(int i=1;i<=N;i++){
            cs[i]=0;
            csp[i]=0;
        }
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++){
            cin>>d[i]>>v[i]>>a[i];
        }
        for(int i=1;i<=m;i++){
            cin>>p[i];
            for(int j=1;j<=n;j++){
                if(cs[j]==0&&d[j]<=p[i]){
                    if(judge(p[i]-d[j],v[j],a[j],V)){
                        cs[j]=1;
                        csp[i]=1;
                    }
                }
            }
        }
        for(int i=1;i<=n;i++){
            if(cs[i]==1)ans1++;
        }
        for(int i=1;i<=m;i++){
            if(csp[i]==0)ans2++;
        }
        cout<<ans1<<" "<<ans2<<endl;

    }
    return 0;
}
